﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Proyecta.Usuarios
{
    public partial class Index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet ds = null;
            Proyecta.Data.BO.UsuariosBO bo = new Data.BO.UsuariosBO();
            Proyecta.Data.DAO.UsuariosDAO dao = new Data.DAO.UsuariosDAO();

            ds = dao.Mostrar(bo);
            GridView1.DataSource = ds;
            GridView1.DataBind();
        }
        public void redireccionar()
        {
            Response.Redirect("Usuarios");
        }

        protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            e.Cancel = true;
            GridView1.EditIndex = -1;
            GridView1.DataBind();
        }

        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridView1.EditIndex = e.NewEditIndex;
            GridView1.DataBind();
        }

        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Proyecta.Data.BO.UsuariosBO bo = new Data.BO.UsuariosBO();
            GridViewRow row = GridView1.Rows[e.RowIndex];

            bo.idUsuario = int.Parse(((TextBox)(row.Cells[1].Controls[0])).Text);

            GridView1.EditIndex = -1;
            GridView1.DataBind();
            Response.Redirect("Usuarios.aspx?id=" + bo.idUsuario + "");
        }
    }
}